
<style>
    .input_line{
        border-bottom: 1px solid #000;
        border-top: 0px;
        border-left: 0px;
        border-right: 0px;
        outline: none;
    }
</style>
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="print_div">
    <form class="form-horizontal m" id="form-psychologicaRecord-add" th:object="${examPaper}">
        <input type="hidden" th:name="testId" th:value="*{id}">

        <div class="form-group">
            <div class="col-sm-12 m-auto text-center">
                <h3>[[*{name}]]</h3>
                <p>[[*{gradeName}]] [[*{subjectName}]] 时间:[[*{duration}]]分钟 </p>
                <p>姓名:

                    <input type="text" class="input_line" style="width:80px;"/>

                    班级:
                    <input type="text" class="input_line" style="width:80px;"/>

                    成绩:
                    <input type="text" class="input_line" style="width:80px;"/>
                    （满分[[*{totalScore}]]分）
                </p>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <div th:utext="*{description}">
                </div>
            </div>
        </div>


        <div th:each="question,stat:*{questionList}" class="form-group col-md-offset-4">

            <div class=" m-l m-r-xs" >
                <strong class="m-b-lg">[[${stat.index+1}]].</strong>

                <span th:utext="${question['content']}"></span>

            </div>

            <div class="col-sm-10 checkbox m-l m-r-xs" th:each="answer:${question['answerList']}">
                <!--单选-->
                <div th:if="${question['type']} eq 1">
                    <div class="radio">
                        <label>
                            <span th:utext="${answer['content']}"></span>
                        </label>
                    </div>
                </div>
                <!--多选-->
                <div th:if="${question['type']} eq 4">
                    <div class="checkbox">
                        <label>
                            <span th:utext="${answer['content']}"></span>
                        </label>
                    </div>
                </div>

            </div>

            <!--简答题-->
            <div th:if="${question['type'] eq 3 || question['type'] eq 5 || question['type'] eq 6} " class="col-sm-10">

                <br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>

            </div>

            <!--论述题-->
            <div th:if="${question['type']} eq 7" class="col-sm-10">

                <br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>
                <hr/><br/>
            </div>

        </div>

        <div>
            <input type="hidden" id="score" name="score">
            <input type="hidden" id="answer" name="answer">
            <input type="hidden" name="testUserId" th:value="${(user.userId)}">
            <input type="hidden" name="testUserName" th:value="${(user.userName)}">
        </div>

    </form>



</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "school/psychologicaRecord"
    $("#form-psychologicaTest-add").validate({
        focusCleanup: true
    });

    function submitHandler() {

        if ($.validate.form()) {
            var itemArray = [];
            $("input:radio:checked").each(function(i) {
                var item = {};
                var score = $(this).val();

                var itemId = $(this).attr("item-id");

                item["itemId"] = itemId;
                item["score"] = score;
                itemArray.push(item);

            });
            var data = JSON.stringify(itemArray);
            $("#answer").val(data);
            var res = $('#form-psychologicaRecord-add').serialize();

            $.operate.save(prefix + "/add", $('#form-psychologicaRecord-add').serialize());
        }
    }

    $(document).ready(function() {
        $('input[type=radio]').change(function() {

            var score = 0;

            $("input:radio:checked").each(function(i) {

                var val = $(this).val();
                score =parseInt(score)+parseInt(val);

            });

            $("#total_score_p").html(score);
            $("#score").val(score);

        });
    });


</script>
